import 'package:flutter/material.dart';
import '../components/mysliver.dart';

Color bg = const Color(0xFFf4f4f4);
Color btnBg = const Color(0xFFFF8954);
final items = new List<String>.generate(10000, (i) => "Item $i");

class Home extends StatefulWidget {
  @override
  HomeState createState() => new HomeState();
}

class HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: '首页',
      home: new Scaffold(
        body: Container(
          height: double.infinity,
          color: bg,
          child: SliverScreen(),
          // child:SingleChildScrollView(
          //   child: Column(
          //     children: <Widget>[
          //       CarouselWithIndicator(),
          //       NotificationsCom(),
          //       RecommendProCom(),
          //       // MyListView(),
          //       ProList(items: items)
          //     ] 
          //   )
          )
        )
    );
  }
}


class RecommendProCom extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color:  Colors.white,
      height: 43,
      margin: const EdgeInsets.only(top: 10.0),
      padding:const EdgeInsets.only(left: 10.0),
      child: Row(
        children: <Widget>[
          Row(
            children:<Widget>[
              Icon(Icons.whatshot,color: Colors.red),
              Text('产品推荐', style: TextStyle(color: Colors.red))
            ]
          ),
          new Expanded(
            child: Center(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children:<Widget>[
                  Text('查看更多'),
                  Icon(Icons.keyboard_arrow_right),
                ]
              ),
            )
          )
        ]
      )
    );
  }
}

class MyListView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scrollbar(
      child: SingleChildScrollView(
        child: new ListView(
          padding: const EdgeInsets.all(0.0),
          shrinkWrap: true,
          children: <Widget>[
            Container(
              color: Colors.white,
              margin: const EdgeInsets.only(bottom: 5.0),
              child:new ListTile(
                title:new Text('及贷',style: TextStyle(fontWeight: FontWeight.w500),),
                subtitle: new Row(
                  children: <Widget>[
                    new Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        new Text('1000~3000元',style: TextStyle(color: btnBg)),
                        new Text('可贷金额'),
                      ]
                    ),
                    new Expanded(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children:<Widget>[
                          new Column(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: <Widget>[
                              new Text('0.4%', style: TextStyle(color: btnBg)),
                              new Text('日利率'),
                            ]
                          ),
                          
                        ]
                      )
                    )
                  ],
                ),
                leading: Image(
                  image: AssetImage("images/pro_01.jpg"),
                  width: 48.0
                ),
                trailing: new RaisedButton(
                  // padding: new EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding
                  child: new Text(
                    '立即借款',
                    style: new TextStyle(
                      fontSize: 14.0, //textsize
                      color: Colors.white,// textcolor
                    ),
                  ),
                  color: btnBg,
                  elevation: 4.0,  //shadow
                  splashColor: Colors.blueGrey, 
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(25.0)),
                  ),
                  onPressed: () {
                  }
                ),
              ),
            ),
            Container(
              color: Colors.white,
              margin: const EdgeInsets.only(bottom: 5.0),
              child:new ListTile(
                title:new Text('信用钱包',style: TextStyle(fontWeight: FontWeight.w500),),
                subtitle: new Row(
                  children: <Widget>[
                    new Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        new Text('2000~8000元',style: TextStyle(color: btnBg)),
                        new Text('可贷金额'),
                      ]
                    ),
                    new Expanded(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children:<Widget>[
                          new Column(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: <Widget>[
                              new Text('0.7%', style: TextStyle(color: btnBg)),
                              new Text('日利率'),
                            ]
                          ),
                        ]
                      )
                    )
                  ],
                ),
                leading: Image(
                  image: AssetImage("images/pro_02.jpg"),
                  width: 48.0
                ),
                trailing: new RaisedButton(
                  // padding: new EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding
                  child: new Text(
                    '立即借款',
                    style: new TextStyle(
                      fontSize: 14.0, //textsize
                      color: Colors.white,// textcolor
                    ),
                  ),
                  color: btnBg,
                  elevation: 4.0,  //shadow
                  splashColor: Colors.blueGrey, 
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(25.0)),
                  ),
                  onPressed: () {
                  }
                ),
              ),
            ),
            Container(
              color: Colors.white,
              margin: const EdgeInsets.only(bottom: 5.0),
              child:new ListTile(
                title:new Text('信用钱包',style: TextStyle(fontWeight: FontWeight.w500),),
                subtitle: new Row(
                  children: <Widget>[
                    new Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        new Text('2000~8000元',style: TextStyle(color: btnBg)),
                        new Text('可贷金额'),
                      ]
                    ),
                    new Expanded(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children:<Widget>[
                          new Column(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: <Widget>[
                              new Text('0.7%', style: TextStyle(color: btnBg)),
                              new Text('日利率'),
                            ]
                          ),
                        ]
                      )
                    )
                  ],
                ),
                leading: Image(
                  image: AssetImage("images/pro_03.jpg"),
                  width: 48.0
                ),
                trailing: new RaisedButton(
                  // padding: new EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding
                  child: new Text(
                    '立即借款',
                    style: new TextStyle(
                      fontSize: 14.0, //textsize
                      color: Colors.white,// textcolor
                    ),
                  ),
                  color: btnBg,
                  elevation: 4.0,  //shadow
                  splashColor: Colors.blueGrey, 
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(25.0)),
                  ),
                  onPressed: () {
                  }
                ),
              ),
            ),
            Container(
              color: Colors.white,
              margin: const EdgeInsets.only(bottom: 5.0),
              child:new ListTile(
                title:new Text('信用钱包',style: TextStyle(fontWeight: FontWeight.w500),),
                subtitle: new Row(
                  children: <Widget>[
                    new Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        new Text('2000~8000元',style: TextStyle(color: btnBg)),
                        new Text('可贷金额'),
                      ]
                    ),
                    new Expanded(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children:<Widget>[
                          new Column(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: <Widget>[
                              new Text('0.7%', style: TextStyle(color: btnBg)),
                              new Text('日利率'),
                            ]
                          ),
                        ]
                      )
                    )
                  ],
                ),
                leading: Image(
                  image: AssetImage("images/pro_02.jpg"),
                  width: 48.0
                ),
                trailing: new RaisedButton(
                  // padding: new EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding
                  child: new Text(
                    '立即借款',
                    style: new TextStyle(
                      fontSize: 14.0, //textsize
                      color: Colors.white,// textcolor
                    ),
                  ),
                  color: btnBg,
                  elevation: 4.0,  //shadow
                  splashColor: Colors.blueGrey, 
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(25.0)),
                  ),
                  onPressed: () {
                  }
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}


class ProList extends StatelessWidget {
  final List<String> items;

  ProList({Key key, @required this.items}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 200,
      child: new ListView.builder(
        itemCount: items.length,
        itemBuilder: (context, index) {
          return new ListTile(
            title: new Text('${items[index]}'),
          );
        },
      )
    );
  }
}